home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Zope.exe / FINDHOMES.PY < prev    next >
Encoding:
Python Source  |  2000-06-30  |  5.6 KB  |  145 lines

  1. ##############################################################################
  2. # Zope Public License (ZPL) Version 1.0
  3. # -------------------------------------
  4. # Copyright (c) Digital Creations.  All rights reserved.
  5. # This license has been certified as Open Source(tm).
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are
  8. # met:
  9. # 1. Redistributions in source code must retain the above copyright
  10. #    notice, this list of conditions, and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. #    notice, this list of conditions, and the following disclaimer in
  13. #    the documentation and/or other materials provided with the
  14. #    distribution.
  15. # 3. Digital Creations requests that attribution be given to Zope
  16. #    in any manner possible. Zope includes a "Powered by Zope"
  17. #    button that is installed by default. While it is not a license
  18. #    violation to remove this button, it is requested that the
  19. #    attribution remain. A significant investment has been put
  20. #    into Zope, and this effort will continue if the Zope community
  21. #    continues to grow. This is one way to assure that growth.
  22. # 4. All advertising materials and documentation mentioning
  23. #    features derived from or use of this software must display
  24. #    the following acknowledgement:
  25. #      "This product includes software developed by Digital Creations
  26. #      for use in the Z Object Publishing Environment
  27. #      (http://www.zope.org/)."
  28. #    In the event that the product being advertised includes an
  29. #    intact Zope distribution (with copyright and license included)
  30. #    then this clause is waived.
  31. # 5. Names associated with Zope or Digital Creations must not be used to
  32. #    endorse or promote products derived from this software without
  33. #    prior written permission from Digital Creations.
  34. # 6. Modified redistributions of any form whatsoever must retain
  35. #    the following acknowledgment:
  36. #      "This product includes software developed by Digital Creations
  37. #      for use in the Z Object Publishing Environment
  38. #      (http://www.zope.org/)."
  39. #    Intact (re-)distributions of any official Zope release do not
  40. #    require an external acknowledgement.
  41. # 7. Modifications are encouraged but must be packaged separately as
  42. #    patches to official Zope releases.  Distributions that do not
  43. #    clearly separate the patches from the original work must be clearly
  44. #    labeled as unofficial distributions.  Modifications which do not
  45. #    carry the name Zope may be packaged in any form, as long as they
  46. #    conform to all of the clauses above.
  47. # Disclaimer
  48. #   THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
  49. #   EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  50. #   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  51. #   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
  52. #   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  53. #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  54. #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  55. #   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  56. #   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  57. #   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  58. #   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59. #   SUCH DAMAGE.
  60. # This software consists of contributions made by Digital Creations and
  61. # many individuals on behalf of Digital Creations.  Specific
  62. # attributions are listed in the accompanying credits file.
  63. ##############################################################################
  64.  
  65. """Commonly used utility functions."""
  66.  
  67. __version__='$Revision: 1.3.36.1 $'[11:-2]
  68.  
  69. import os, sys, Products, string
  70. from Common import package_home
  71. path_join = os.path.join
  72. path_split = os.path.split
  73.  
  74. try: home=os.environ['SOFTWARE_HOME']
  75. except:
  76.     home=package_home(Products.__dict__)
  77.     if not os.path.isabs(home):
  78.         home=path_join(os.getcwd(), home)
  79.         
  80.     home,e=path_split(home)
  81.     if path_split(home)[1]=='.': home=path_split(home)[0]
  82.     if path_split(home)[1]=='..':
  83.         home=path_split(path_split(home)[0])[0]
  84.  
  85. sys.modules['__builtin__'].SOFTWARE_HOME=SOFTWARE_HOME=home
  86.  
  87. try: chome=os.environ['INSTANCE_HOME']
  88. except:
  89.     chome=home
  90.     d,e=path_split(chome)
  91.     if e=='python':
  92.         d,e=path_split(d)
  93.         if e=='lib': chome=d or os.getcwd()
  94.     
  95. sys.modules['__builtin__'].INSTANCE_HOME=INSTANCE_HOME=chome
  96.  
  97. # If there is a Products package in INSTANCE_HOME, add it to the
  98. # Products package path
  99. ip=path_join(INSTANCE_HOME, 'Products')
  100. ippart = 0
  101. ppath = Products.__path__
  102. if os.path.isdir(ip) and ip not in ppath:
  103.     disallow=string.lower(os.environ.get('DISALLOW_LOCAL_PRODUCTS',''))
  104.     if disallow in ('no', 'off', '0', ''):
  105.         ppath.insert(0, ip)
  106.         ippart = 1
  107.         
  108. ppathpat = os.environ.get('PRODUCTS_PATH', None)
  109. if ppathpat is not None:
  110.     psep = os.pathsep
  111.     if string.find(ppathpat, '%(') >= 0:
  112.         newppath = string.split(ppathpat % {
  113.             'PRODUCTS_PATH': string.join(ppath, psep),
  114.             'SOFTWARE_PRODUCTS': string.join(ppath[ippart:], psep),
  115.             'INSTANCE_PRODUCTS': ip,
  116.             }, psep)
  117.     else:
  118.         newppath = string.split(ppathpat, psep)
  119.     del ppath[:]
  120.     for p in filter(None, newppath):
  121.         p = os.path.abspath(p)
  122.         if os.path.isdir(p) and p not in ppath:
  123.             ppath.append(p)
  124.